package com.the_ring.chapter06;

import android.content.SharedPreferences;
import android.os.Bundle;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        SharedPreferences share = getSharedPreferences("share", MODE_PRIVATE);

        // 数据写入
        SharedPreferences.Editor editor = share.edit();
        editor.putString("name", "张三");
        editor.commit();

        // 数据读取
        share.getString("name", "李四");
    }
}